package com.hippo.core.service;

import com.alibaba.fastjson.JSONObject;
import com.hippo.core.dao.RecordDao;
import com.hippo.core.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: hippo
 */
@Service
public class RecordService {

    @Autowired
    private RecordDao recordDao;

    public JSONObject getRecordList(JSONObject jsonObject) {
        CommonUtil.fillPageParam(jsonObject);
        int count = recordDao.countRecord(jsonObject);
        List<JSONObject> list = recordDao.getRecordList(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
    }

    public JSONObject addRecord(JSONObject data) {
        return CommonUtil.response(recordDao.addRecord(data));
    }

    public JSONObject deleteRecord(String id) {
        return CommonUtil.response(recordDao.deleteRecord(id));
    }
}
